<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>赎回申请</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <%--<jsp:include page="assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->--%>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>--------项目及还款信息--------</span>
            </div>
        </div>
        <div id="pageInTab" class="pageInTab">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">合同编号</div>
                    <div class="field">
                        <span name="lsCntNo" id="lsCntNo">${redm.lsCntNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">承租人名称</div>
                    <div class="field">
                        <span>${redm.cstNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">第三方机构</div>
                    <div class="field">
                        <span>${redm.fundRasInsNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">租赁期数</div>
                    <div class="field">
                        <span name="lsPd" id="lsPd">${redm.lsPd}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合同总金额</div>
                    <div class="field">
                        <span>${redm.contAmt == null ? 0 : redm.contAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资总金额</div>
                    <div class="field">
                        <span>${redm.actLsAmt == null ? 0 : redm.actLsAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实际应收金额</div>
                    <div class="field">
                        <span>${redm.relActAmt == null ? 0 : redm.relActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">应收租金合计</div>
                    <div class="field">
                        <span>${redm.totalActAmt == null ? 0 : redm.totalActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实收租金合计</div>
                    <div class="field">
                        <span>${redm.totalRelRcptAmt == null ? 0 : redm.totalRelRcptAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期金额</div>
                    <div class="field">
                        <span>${redm.ovdAmt == null ? 0 : redm.ovdAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">罚息金额</div>
                    <div class="field">
                        <span>${redm.pnlAmt == null ? 0 : redm.pnlAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期天数</div>
                    <div class="field">
                        <span>${redm.ovdDay == null ? 0 : redm.ovdDay}</span>
                    </div>
                </div>
            </div>

            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>--------项目产品信息及放款信息--------</span>
                </div>
            </div>
            <!-- 列表显示块 -->
            <div id="ligergrid3" class="sq-grid"></div>
            <!--赎回原因-->
            <form id="insRedmApplyForm">
            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>--------赎回原因--------</span>
                </div>
            </div>
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">赎回原因</div>
                    <div class="field">
                        <input name="insRedmReson" id="insRedmReson" data-value=" " placeholder="--请选择--" ltype="combobox" onchange="clearInsRedmReson()">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">具体原因</div>
                    <div class="field">
                        <input name="insRedmDetailReson" id="insRedmDetailReson" data-value=" " placeholder="--请选择--" ltype="combobox" onchange="">
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">其他原因</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="otherInsRedmReson" id="otherInsRedmReson" rows="5" class="ui-textarea l-textarea" style="width:99%"></textarea>
                    </div>
                </div>
                <div class="fieldBox col_100" id="fileDiv" >
                    <div class="label">上传附件</div>
                    <div class="field">
                        <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                            <jsp:param name="filePath" value="/prjRedm"/>
                        </jsp:include>
                    </div>
                </div>
                <!-- 附件显示 -->
                <!--<div class="fieldBox col_100">
                    <div style="width: 98%; margin-left: 1%;">
                        <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" ></jsp:include>
                    </div>
                </div>-->
            </div>

            <!--资方赎回信息-->
            <c:if test="${isShowInsRedmInterfaceInfo == 1 && redm.payerStsCd == '2'}">
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------资方赎回接口信息--------</span>
                    </div>
                </div>
                <!-- 资方赎回接口显示块 -->
                <div id="ligergrid2" class="sq-grid"></div>
            </c:if>
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------资方赎回信息--------</span>
                    </div>
                </div>
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">是否已经线下赎回</div>
                        <div class="field">
                            <select name="offlineSettle" onchange="changeOfflineSettle()"  id="offlineSettle" >
                                <option value="1" selected="selected">是</option>
                                <option value="0">否</option>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33" id="insRedmTmDiv">
                        <div class="label">线下赎回时间</div>
                        <div class="field">
                            <input name="insRedmTm" id="insRedmTm" type="text" class="ui-datepicker" value=""
                                   validate="">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33" id="redmTotalAmtDiv">
                        <div class="label">赎回金额合计</div>
                        <div class="field">
                            <input name="redmTotalAmt" id="redmTotalAmt" readonly="readonly" type="text" class="ui-textbox" value="">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33" id="redmPrinAmtDiv">
                        <div class="label">赎回本金</div>
                        <div class="field">
                            <input name="redmPrinAmt" id="redmPrinAmt" type="text" class="ui-textbox" value="" validate="">
                        </div>
                    </div>
                    <div class="fieldBox col_33" id="redmIntAmtDiv">
                        <div class="label">赎回利息</div>
                        <div class="field">
                            <input name="redmIntAmt" id="redmIntAmt" type="text" class="ui-textbox"  value="" validate="">
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">赎回罚息</div>
                        <div class="field">
                            <input name="redmPnlAmt" id="redmPnlAmt" type="text" class="ui-textbox" value=""
                                   validate="{required:true,number:true, maxlength:22, minlength:1}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <!--新增三方放款状态判断-->
                    <div class="fieldBox col_33">
                        <div class="label">资方放款结果</div>
                        <div class="field">
                                <c:if test="${redm.payerStsCd == '0'}">
                                    <span>未申请</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '1'}">
                                    <span>申请中</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '2'}">
                                    <span>放款通过</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '3'}">
                                    <span>拒绝放款</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '4'}">
                                    <span>已赎回</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '5'}">
                                    <span>已赎回结清</span>
                                </c:if>
                        </div>
                    </div>
                    <!--新增字段-->
                    <div class="fieldBox col_33">
                        <div class="label">是否上报征信(融担)</div>
                        <div class="field">
                            <select name="isSubmitCreditRD" onchange="changeIsSubmitCreditRD()"  id="isSubmitCreditRD" >
                                <option value="2" selected="selected">是</option>
                                <option value="1">否</option>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>

                    <div class="fieldBox col_33">
                        <div class="label">回购主体</div>
                        <div class="field">
                            <select name="suretySubjectCode" id="suretySubjectCode" >
                                <option value=" " selected="selected">--请选择--</option>
                                <c:forEach items="${suretySubjectCodeList}" var="opt">
                                    <option value="${opt.key}">${opt.value}</option>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">付款方式</div>
                        <div class="field">
                            <c:if test="${repayMode == '0'}">
                                <span>资方划扣</span>
                            </c:if>
                            <c:if test="${repayMode == '1'}">
                                <span>拜特打款</span>
                            </c:if>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">我司赎回付款账户</div>
                        <div class="field">
                            <select name="redmPaymentAccountNum" id="redmPaymentAccountNum" >
                                <c:forEach items="${redmPaymentAccountDtoList}" var="opt">
                                    <option value="${opt.accNum}">${opt.accNm}${opt.accNum}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">资方赎回收款账户</div>
                        <div class="field">
                            <select name="redmPayeeAccountNum" id="redmPayeeAccountNum" >
                                <c:forEach items="${redmPayeeAccountDtoList}" var="opt">
                                    <option value="${opt.accNum}">${opt.accNm}${opt.accNum}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">打款备注</div>
                        <div class="field">
                            <input name="paymentReason" id="paymentReason" type="text" class="ui-textbox"  value="" validate="">
                        </div>
                    </div>
                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${redm.prjId}">
                            <input name="payerStsCd" id="payerStsCd" type="text" class="ui-textbox" value="${redm.payerStsCd}">
                            <input name="repayMode" id="repayMode" type="text" class="ui-textbox" value="${repayMode}">

                        </div>
                    </div>
                </div>
                <div id="saveInsCfgDiv" class="btnsBox">
                    <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存并发起流程</span>
                </div>
            </form>


        </div>
    </div>
</div>

<script type="text/javascript">
    var repayGrid = null;
    var payerStsCd = '${redm.payerStsCd}';
    var isShowInsRedmInterfaceInfo = '${isShowInsRedmInterfaceInfo}';
    var insCode = '${redm.insCode}';
    var paySchId = '${redm.paySchId}';
    var paySchNo = '${redm.paySchNo}';
    //支付表是否逾期
    var isOverdue = '${redm.isOverdue}';
    var grid1 = null;
    //机构id
    var fundRasInsId = '${redm.fundRasInsId}';
    //机构试算是否需要核销逾期
    var isChargeOffOvd = '${isChargeOffOvd}';
    $(function () {
        initGrid();
        if(isShowInsRedmInterfaceInfo == '1'){
            initGrid1();
        }
        var insRedmApplyForm = liger.get("insRedmApplyForm");
        var ligerForm = $("#insRedmApplyForm").ligerForm({
            validate: true
        });
        $("#insRedmReson").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:200,
            onChangeValue:function(value){
                if(value){
                    initInsRedmDetailResonSelectData(value);
                }else{
                    var detailResonSelectObj = liger.get("insRedmDetailReson");
                    detailResonSelectObj.selectValue(" ");
                }
            }
        });
        $("#insRedmDetailReson").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            width:300
        });
        //初始化赎回原因
        initInsRedmResonSelectData();
    });


    //初始化列表
    function initGrid() {
        var prjId = $("#prjId").val();
        $("#ligergrid3").ligerGrid({
            // data: data,
            method: 'get',
            url: '<%=path%>/institution/prjinsredminfo/initPrjDtlInfo.do?prjId=' + prjId,
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, enabledSort: true,},
                {
                    display: '我司是否已放款', name: 'isOCPay', width: 200, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "";
                        if (rowdata.isOCPay == 0) {
                            h = "否";
                        }
                        if (rowdata.isOCPay == 1) {
                            h = "是";
                        }
                        return h;
                    }
                },
                {display: '设备名', name: 'prdNm', width: 200, enabledSort: true,},
                {display: '车辆型号', name: 'prdMdl', width: 200, enabledSort: true},
                {display: '合格证编号', name: 'certNo', width: 200, enabledSort: true},
                {display: 'VIN', name: 'vin', width: 200, enabledSort: true}
            ],
            onAfterShowData: function (e) {
                var rows = e.rows;
                var i = 0;
                for (var index in rows) {
                    i += rows[index].arAmt;
                }
                $("#arAmts").text(i);
            },
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            isScroll: false,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
        repayGrid = liger.get("ligergrid3");
        //grid.setHeight(100);
        repayGrid.options.isSingleCheck = true;//列表是否为单选
    }

    //初始化资方赎回列表
    function initGrid1() {
        var prjId = $("#prjId").val();
        var data = 'prjId='+prjId+'&paySchId='+paySchId+'&paySchNo='+paySchNo+'&insCode='+insCode+'&payerStsCd='+payerStsCd;

        grid1 = $("#ligergrid2").ligerGrid({
            method: 'get',
            url: '<%=path%>/institution/prjinsredminterfaceinfo/initInsRedmInterfaceInfo.do?'+data,
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, enabledSort: true,},
                {display: '时间', name: 'crtTm', width: 200, enabledSort: true,render: renderDate},
                {display: '赎回金额合计', name: 'redmAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.redmAmt;

                        }
                    }
                },
                {display: '本金', name: 'principalAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+ rowdata.principalAmt;

                        }
                    }
                },
                {display: '利息', name: 'interestAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.interestAmt;

                        }
                    }
                },
                {display: '罚息', name: 'penaltyAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.penaltyAmt;

                        }
                    }
                },
                {display: '动作', name: 'operationType', width: 200, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "";
                        if (rowdata.payerStsCd == 2) {
                            h += '<a href="javascript:calculateInsRedmInfo(';
                            h += "'" + rowdata.prjId + "',";
                            h += "'" + rowdata.paySchId + "',";
                            h += "'" + rowdata.insCode + "',";
                            h += "'" + rowdata.fundRasInsId + "'";
                            h += ')">试算</a>';
                        }else{
                            if(rowdata.operationType == '0'){
                                h += '试算';
                            }
                            if(rowdata.operationType == '1'){
                                h += '赎回';
                            }
                        }
                        return h;
                    }
                }
            ],
            onAfterShowData: function (e) {
            },
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            isScroll: false,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
    }

    //新增还款信息等
    function saveInfo() {
        var insRedmApplyForm = liger.get("insRedmApplyForm");
        if (!insRedmApplyForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = insRedmApplyForm.getData();
        var fileParams = getUploadResultParams();//获取附件上传的信息
        data["fileParams"] = JSON.stringify(fileParams);
        if(data.isSubmitCreditRD == ' '){
            top.$.ligerDialog.SQalert({content: "请维护【是否上报征信】", SQ_type: "warning"});
            return false;
        }
        if(data.suretySubjectCode == ' '){
            top.$.ligerDialog.SQalert({content: "请维护【回购主体】", SQ_type: "warning"});
            return false;
        }
        if(data.insRedmReson == ''){
            top.$.ligerDialog.SQalert({content: "请选择赎回原因", SQ_type: "warning"});
            return false;
        }
        if(data.insRedmDetailReson == ''){
            top.$.ligerDialog.SQalert({content: "请选择具体原因", SQ_type: "warning"});
            return false;
        }
        if(data.insRedmDetailReson == '99'){
            if(data.otherInsRedmReson === ''){
                top.$.ligerDialog.SQalert({content: "请维护其他原因", SQ_type: "warning"});
                return false;
            }
        }
        if(payerStsCd == '2'){
            //是否校验试算接口
            if(isShowInsRedmInterfaceInfo == 1){
                var targetRow = grid1.rows[0];
                var redmAmt = targetRow.redmAmt;
                //华润 浦发支付表逾期 不用进行试算
                if(isChargeOffOvd == 1){
                    if(isOverdue == 1){
                        top.$.ligerDialog.SQalert({content: "请务必今天内操作来款", SQ_type: "warning"});
                    }
                }
            }else{
                //未对接线上赎回接口资方 赎回本金 赎回利息 必填
                if(data.redmPrinAmt == ''){
                    top.$.ligerDialog.SQalert({content: "资方已放款,赎回本金不能为空", SQ_type: "warning"});
                    return false;
                }
                if(data.redmIntAmt == ''){
                    top.$.ligerDialog.SQalert({content: "资方已放款,赎回利息不能为空", SQ_type: "warning"});
                    return false;
                }

            }

        }
        var wait_dialog = null;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: '<%=path%>/institution/prjinsredminfo/add.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    setInterval('Remove_navTab();callback();',1000);
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    /**
     * 试算
     */
    function calculateInsRedmInfo(prjId,paySchId,insCode,fundRasInsId) {
        //浦发赎回 逾期不能发起试算
        if(isChargeOffOvd == '1' && isOverdue == '1'){
            $.ligerDialog.SQalert({content: "逾期情况,不支持试算,请直接发起流程", SQ_type: "error"});
            return;
        }
        var data = {prjId:prjId,paySchId:paySchId,insCode:insCode,fundRasInsId:fundRasInsId};
        $.ajax({
            type: 'post',
            dataType: 'json',
            data : data,
            url: '<%=path%>/institution/prjinsredminterfaceinfo/calculateInsRedmInterfaceInfo.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //回填数据
                    if("000194" != msg.code){
                        var targetRow = grid1.rows[0];
                        var redmValue= "";
                        var principalAmtValue= "";
                        var interestAmtValue= "";
                        var penaltyAmtValue= "";
                        if(msg.data.redmAmt != null && msg.data.redmAmt !== ''){
                            redmValue= msg.data.redmAmt;
                        }
                        if(msg.data.principalAmt != null && msg.data.principalAmt !== ''){
                            principalAmtValue = msg.data.principalAmt;
                        }
                        if(msg.data.interestAmt != null && msg.data.interestAmt !== ''){
                            interestAmtValue = msg.data.interestAmt;
                        }
                        if(msg.data.penaltyAmt != null && msg.data.penaltyAmt !== ''){
                            penaltyAmtValue = msg.data.penaltyAmt;
                        }
                        var crtTm = msg.data.crtTm;
                        grid1.updateCell('redmAmt',redmValue, targetRow);
                        grid1.updateCell('principalAmt',principalAmtValue, targetRow);
                        grid1.updateCell('interestAmt',interestAmtValue, targetRow);
                        grid1.updateCell('penaltyAmt',penaltyAmtValue, targetRow);
                        grid1.updateCell('crtTm',crtTm, targetRow);
                        $("#redmTotalAmt").val(redmValue);
                        $("#redmPrinAmt").val(principalAmtValue);
                        $("#redmIntAmt").val(interestAmtValue);
                        $("#redmPnlAmt").val(penaltyAmtValue);
                    }
                    if("000194" == msg.code){
                        $.ligerDialog.SQalert({content: "资方已结清,无需试算,请直接发起赎回流程", SQ_type: "error"});
                    }
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        if(value == null || value == undefined ){
            return '';
        }
        var h = "￥" + FormatMoney(value);
        return h;
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }


    /**
     * 是否上报征信
     */
    function changeIsSubmitCreditRD(){
        $("#suretySubjectCode").val(" ");
        $.each($('#suretySubjectCode option'), function(i, n) {
            if ($(n).val() === " ") {
                $(n).attr('selected', 'selected');
            }
        });
    }

    function setValidate(validate) {
        var formSet = liger.get("insRedmApplyForm");
        if (validate) {
            formSet.setFieldValidate("redmPrinAmt", {required: true, amount: true});
            formSet.setFieldValidate("redmIntAmt", {required: true, amount: true});
            //formSet.setFieldValidate("insRedmTm", {required: true, amount: true});
        } else {
            formSet.setFieldValidate("redmPrinAmt", {required: false});
            formSet.setFieldValidate("redmIntAmt", {required: false});
            //formSet.setFieldValidate("insRedmTm", {required: false});
        }
    }

    function changeOfflineSettle(){
        var formSet = liger.get("insRedmApplyForm");
        var offlineSettle = $("#offlineSettle").val();
        if(offlineSettle == '1'){
            $("#redmPrinAmtDiv").show();
            $("#redmIntAmtDiv").show();
            $("#insRedmTmDiv").show();
        }else{
            if(isChargeOffOvd == '1'){
                $("#redmPrinAmtDiv").hide();
                $("#redmIntAmtDiv").hide();
            }
            $("#insRedmTmDiv").hide();
        }
    }

    //初始化赎回原因
    function initInsRedmResonSelectData(){
        var data = {isPcode: '1',sysCode:'REDM008'};
        $.ajax({
            type: 'post',
            dataType:'json',
            data : data,
            url: '<%=path%>/institution/prjinsredminfo/getInsRedmReson.do',
            success:function(msg){
                if(msg.success == 1){
                    var insRedmResonSelectObj = liger.get("insRedmReson");
                    insRedmResonSelectObj.setData(msg.data);
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }


    //初始化具体原因
    function initInsRedmDetailResonSelectData(value){
        if(!$("#insRedmReson").length)return;
        var insRedmResonSelectObj = liger.get("insRedmReson");
        var pCode = insRedmResonSelectObj.findValueByText(value);
        var data = {isPcode: '0',sysCode:'REDM009',pCode:pCode};
        $.ajax({
            type: 'post',
            dataType:'json',
            data:data,
            url: '<%=path%>/institution/prjinsredminfo/getInsRedmReson.do',
            success:function(msg){
                if(msg.success == 1){
                    var insRedmDetailResonSelectObj = liger.get("insRedmDetailReson");
                    if(msg.data){
                        insRedmDetailResonSelectObj.setData(msg.data);
                    }else{
                        insRedmDetailResonSelectObj.clear();
                        insRedmDetailResonSelectObj.setData({});//置空下拉框数据
                    }
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function clearInsRedmReson(){
        var insRedmResonObj = liger.get("insRedmReson");
        var _insRedmReson = insRedmResonObj.getValue();
        if (_insRedmReson == '') {
            var insRedmDetailResonSelectObj = liger.get("insRedmDetailReson");
            if(insRedmDetailResonSelectObj) {
                insRedmDetailResonSelectObj.clear();
                insRedmDetailResonSelectObj.setData({});//置空下拉框数据
            }
        }
    }

</script>
</body>
</html>